/*
package com.lottery.obtainData;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.lottery.dao.qiuqiu.accoutDao.UserDao;
import com.lottery.dao.qiuqiu.lobbyDao.LotteryDao;
import com.lottery.dao.qiuqiu.lobbyDao.WinningResultsDao;
import com.lottery.dao.qiuqiu.wealthDao.AccountDao;
import com.lottery.dto.InfoStateDto;
import com.lottery.dto.Message;
import com.lottery.dto.MessageTube;
import com.lottery.dto.WinningResultsDto;
import com.lottery.entity.Account;
import com.lottery.entity.Lottery;
import com.lottery.entity.LotteryExchange;
import com.lottery.entity.User;
import com.lottery.service.qiuqiu.JedisClient;
import com.lottery.service.qiuqiu.MsgService.MsgNoticeService;
import com.lottery.service.qiuqiu.lobbyService.LotteryDrawService;
import com.lottery.utils.*;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Component
public class SscAchieveData implements Runnable {

	@Autowired
	private LotteryDao lotteryDao;
	@Autowired
	private LotteryDrawService lotteryDrawService;
	@Autowired
	private JedisClient jedisClient;
	@Autowired
	private MsgNoticeService msgNoticeService;
	@Autowired
	private WinningResultsDao winningResultsDao;
	@Autowired
	private AccountDao accountDao;
	@Autowired
	private UserDao userDao;

	private MessageTubes messageTubes = MessageTubes.getInstance();

	// 中奖信息标志key
	@Value("${SSCFLG}")
	private String FLG;
	// 当前开奖的期号
	@Value("${SSCEXPECT}")
	private String EXPECT;
	// 当前开奖的号码
	@Value("${SSCOPENCODE}")
	private String OPENCODE;
	// 当前开奖的时间
	@Value("${SSCOPENDATE}")
	private String OPENDATE;
	// 下一次开奖的时间
	@Value("${SSCNEXTTIME}")
	private String NEXTTIME;
	// 下一次开奖的期号
	@Value("${SSCNEXTEXPECT}")
	private String NEXTEXPECT;
	// 停止下注
	@Value("${STOPBET}")
	private String STOPBET;
	// 开奖接口
	@Value("${SSCLOTTERYINTERFACE}")
	private String LOTTERYINTERFACE;
	// 开始下注
	@Value("${BEGAINBET}")
	private String BEGAINBET;
	// 开始下注
	@Value("${OPENNUM}")
	private String OPENNUM;
	// 开奖信息前缀
	@Value("${BEFOR}")
	private String BEFOR;
	// 开奖信息后缀
	@Value("${AFTER}")
	private String AFTER;

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	private int lotteyType = 1;

	public void run() {
		logger.info("线程启动SscAchieveData:startThreaThrea");
		// 启动时立刻校对期号和对应开奖
		String curFullPeoriod = ObtainDataUtils.getFullPeriod(new Date());//当前时间对应的期号
		 JudgmentCheck(curFullPeoriod);
		// 最近开奖的信息
		Lottery selectLottery = lotteryDao.selectLotteryByExpect(curFullPeoriod);
		if (selectLottery != null) {
			// 当前开奖期号,当前开奖号码,当前开奖时间,
			jedisClient.set(EXPECT, selectLottery.getExpect());
			jedisClient.set(OPENCODE, selectLottery.getOpencode());
		}
		// 下一期开奖时间,下一期开奖期号
		String nextPeoriod = ObtainDataUtils.getNextExpect(curFullPeoriod);
		Date nextPeoriodDate = obtainTime(nextPeoriod);
		String nextDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(nextPeoriodDate);
		jedisClient.set(NEXTEXPECT, nextPeoriod);
		jedisClient.set(NEXTTIME, nextDate);
		// 休眠
		ObtainDataUtils.sleep(nextDate, 30000);
		msgNoticeService.insertPromptNotice(STOPBET, lotteyType);
		ObtainDataUtils.sleep(nextDate, 0);
		while (true) {
			// 休眠间隔3.5秒
			try {
				Thread.sleep(3500);
			} catch (Exception e) {
				logger.info("信息:{}", "休眠异常,继续!");
				continue;
			}
			try {
				// 获得接口数据
				String url = LOTTERYINTERFACE;
				String httpRequest = ObtainDataUtils.obtainData(url);
				if (httpRequest == null) {
					logger.info("接口返回null");
					continue;
				}

				JSONObject parseObject = ObtainDataUtils.stringToJson(httpRequest);
				if (parseObject == null) {
					logger.info("接口获取:{}", httpRequest);
					continue;
				}
				JSONObject nowExpectInfo = JSON.parseObject(String.valueOf(parseObject.getJSONArray("data").get(0)));
				String expect = nowExpectInfo.getString("expect");

				// 从redis中查询上一期的开奖期号
				String expectRedis = jedisClient.get(EXPECT);
				logger.info("redis中的期号:{}", expectRedis);

				// 如果本次获取的开奖信息和上次相同,就结束本次循环
				if (expect.equals(expectRedis)) {
					logger.info("本次获取的开奖期号和redis相同:{}", expectRedis);
					continue;
				} else {
					// 如果本次获取的开奖信息和上次不同,就将本次的开奖信息存入数据库并跟新redis中的内容
					String opencode = nowExpectInfo.getString("opencode");
					Date opentime = nowExpectInfo.getDate("opentime");

					// 查看数据库中是否有该期号的数据,如果有,就结束本次循环
					Lottery selectLotteryByExpect = lotteryDao.selectLotteryByExpect(expect);
					if (selectLotteryByExpect != null) {
						logger.info("数据库已有该记录,结束本次循环");
						continue;
					}

					// 插入数据库
					Boolean insertLottery = insertLottery(expect, Integer.parseInt(expect.substring(8, 11)), opencode,
							opentime);
					if (insertLottery == false) {
						logger.error("插入数据库出错");
						continue;
					}

					// 当前开奖期号,当前开奖号码,当前开奖时间,
					jedisClient.set(EXPECT, expect);
					jedisClient.set(OPENCODE, opencode);
					jedisClient.set(OPENDATE, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(opentime));

					// 下一期开奖时间,下一期开奖期号
					String nextExpect = ObtainDataUtils.getNextExpect(expect);
					Date nextTimeDate = obtainTime(nextExpect);
					String nextTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(nextTimeDate);
					jedisClient.set(NEXTEXPECT, nextExpect);
					jedisClient.set(NEXTTIME, nextTime);
					logger.info("1号接口下次开奖的时间+开奖的期号:{}", nextTime + " + " + nextExpect);

					// 分割字符串
					String[] str = opencode.split(",");
					int amount = Integer.parseInt(str[0]) + Integer.parseInt(str[1]) + Integer.parseInt(str[2])
							+ Integer.parseInt(str[3]) + Integer.parseInt(str[4]);
					String rule = "";
					if (amount >= 23 && amount % 2 != 0) {
						rule = "大单";
					} else if (amount < 23 && amount % 2 != 0) {
						rule = "小单";
					} else if (amount >= 23 && amount % 2 == 0) {
						rule = "大双";
					} else if (amount < 23 && amount % 2 == 0) {
						rule = "小双";
					}

					// 显示开奖号码
					msgNoticeService.insertPromptNotice(
							BEFOR + expect + OPENNUM + opencode.replace(",", " ") + " " + rule + AFTER, lotteyType);
					// 开奖
					//旧规则
					//lotteryDrawService.sscYesWinning(opencode, expect, lotteyType);
					//新规则
					lotteryDrawService.sscYesWinningFactory(opencode, expect, lotteyType);
					// 显示中奖信息
					selectWinningResultsService(expect);
					// 显示开始下注
					msgNoticeService.insertPromptNotice(BEGAINBET, lotteyType);

					// 校验
					// JudgmentCheck(expect);

					logger.info("************************start robot betting ************************");
					// 机器人开始下注

					try {
						PlayWayThread playWayThread = new PlayWayThread();
						playWayThread.setNextTime(nextTime);
						playWayThread.setNextExpect(nextExpect);
						playWayThread.setLotteyType(lotteyType);
						playWayThread.start();
					} catch (Exception e) {
						e.printStackTrace();
						logger.error("create thread error ", e);
					}

					// 休眠
					boolean sleep = ObtainDataUtils.sleep(nextTime, 30000);
					if (sleep == false) {
						logger.info("格式转换异常或休眠异常,结束本次循环");
						continue;
					}
					// 显示停止下注
					msgNoticeService.insertPromptNotice(STOPBET, lotteyType);
					boolean sleepOne = ObtainDataUtils.sleep(nextTime, 0);
					if (sleepOne == false) {
						logger.info("格式转换异常或休眠异常,结束本次循环");
						continue;
					}
				}

			} catch (Exception e) {
				e.printStackTrace();
				logger.error("开奖error:", e);
				continue;
			}

		}

	}

	// 判断校验
	public void JudgmentCheck(String expect) {
		String substring = expect.substring(0, 8);
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
		Date parse = null;
		try {
			parse = simpleDateFormat.parse(substring);
		} catch (ParseException e) {
			logger.info("1号接口日期转换异常:{}", "转换昨天   日期异常");
		}
		Calendar calendar = new GregorianCalendar();
		calendar.setTime(parse);
		calendar.add(Calendar.DATE, -1);// 把日期往后增加一天.整数往后推,负数往前移动
		parse = calendar.getTime();
		String yesterday = simpleDateFormat.format(parse).substring(0, 8) + "120";
		checkOut(yesterday);
		checkOut(expect);

	}

	// 校验数据
	public void checkOut(String expect) {
		logger.info("expect={}", expect);
		List<String> todayExpect = lotteryDao.selectExpectByExpect(expect.substring(0, 8));
		logger.info("todayExpect={}", todayExpect);

		ArrayList<String> lackList = new ArrayList<>();
		// 如果查出来的list长度等于当前期号,则无缺漏
		if (todayExpect.size() == Integer.valueOf(expect.substring(8, 11))) {
			return;
		} else {
			// 有缺漏
			String substring = expect.substring(0, 8);
			// 获得当天所有开奖的期数
			for (int i = 1; i <= Long.valueOf(expect.substring(8, 11)); i++) {
				if (String.valueOf(i).length() == 1) {
					lackList.add(substring + "00" + i);
				}
				if (String.valueOf(i).length() == 2) {
					lackList.add(substring + "0" + i);
				}
				if (String.valueOf(i).length() == 3) {
					lackList.add(substring + i);
				}
			}
			logger.info("当天所有开奖的期数:{}", lackList);
			// 获得缺漏的期数
			for (String string : todayExpect) {
				lackList.remove(string);
			}
			logger.info("缺漏的期数:{}", lackList);
			// 获得校验的模板
			Map<String, String> checkData = checkData(expect);

			// 对照模板补全缺漏的期数,并开奖
			for (String string : lackList) {
				String key = string.substring(8, 11);
				String opencode = checkData.get(key);
				Date opentime = obtainTime(string);

				insertLottery(string, Integer.valueOf(key), opencode, opentime);
				*/
/****** 时时彩待修改 ******************//*

				lotteryDrawService.sscYesWinningFactory(opencode, string, 1);
			}
		}
	}

	// 获取校验模板
	public Map<String, String> checkData(String substring) {
		Document doc = null;
		ArrayList<String> list = new ArrayList<>();
		ArrayList<String> copyList = new ArrayList<>();
		boolean flag = true;
		while (flag) {
			try {
				doc = Jsoup.connect("http://caipiao.163.com/award/cqssc/" + substring + ".html").get();
			} catch (IOException e) {
				e.printStackTrace();
				logger.info("错误信息={}", "拉取html页面出错");
			}
			list = new ArrayList<>();
			Elements trs = doc.select("table").select("tr");
			for (int i = 0; i < trs.size(); i++) {
				Elements tds = trs.get(i).select("td");
				for (int j = 0; j < tds.size(); j++) {
					String text = tds.get(j).text();
					if (isInteger(text.charAt(0) + "")) {
						list.add(text);
					}
				}
			}
			for (String s : list) {
				if (s.length() == 3 && Integer.valueOf(s) > Integer.valueOf(substring.substring(8, 11))) {
				} else {
					copyList.add(s);
				}
			}
			if (copyList.size() % 2 == 1) {
				list.clear();
				copyList.clear();
				flag = true;
				continue;
			}

			break;
		}

		Map<String, String> map = new HashMap<>();
		for (int i = 0; i < copyList.size(); i = i + 2) {
			map.put(copyList.get(i), copyList.get(i + 1).replace(" ", ","));
		}
		logger.info("map={}", map);
		return map;
	}

	// 判断是否为整数
	private static boolean isInteger(String str) {
		Pattern pattern = Pattern.compile("[0-9]+");
		Matcher matcher = pattern.matcher((CharSequence) str);
		return matcher.matches();
	}

	// 开奖时间的获得
	public Date obtainTime(String expect) {
		// 开奖的时间
		String formatDate = expect.substring(0, 4) + "-" + expect.substring(4, 6) + "-" + expect.substring(6, 8);
		String formatMorning = formatDate + " 00:00:00";
		String formatForenoon = formatDate + " 10:00:00";
		String formatEvening = formatDate + " 22:00:00";
		SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long timeMorning = 0;
		long timeForenoon = 0;
		long timeEvening = 0;
		long timeNow = 0;
		try {
			timeMorning = simpleDateFormat.parse(formatMorning).getTime();
			timeForenoon = simpleDateFormat.parse(formatForenoon).getTime();
			timeEvening = simpleDateFormat.parse(formatEvening).getTime();
		} catch (ParseException e) {
			logger.info("错误={}", "日期转换出错");
		}
		Long NextExpectNumber = Long.valueOf(expect.substring(8, 11));
		if (NextExpectNumber >= 1 && NextExpectNumber <= 23) {
			timeNow = timeMorning + 300000 * NextExpectNumber;
		}
		if (NextExpectNumber >= 24 && NextExpectNumber <= 96) {
			timeNow = timeForenoon + 600000 * (NextExpectNumber - 24);
		}
		if (NextExpectNumber >= 97 && NextExpectNumber <= 120) {
			timeNow = timeEvening + 300000 * (NextExpectNumber - 96);
		}
		Date date = new Date(timeNow);
		logger.info("开奖的时间={}", date);
		return date;
	}

	// 将当前开奖信息插入数据库
	public Boolean insertLottery(String expect, int expectNum, String opencode, Date opentime) {
		Lottery lottery = new Lottery();
		lottery.setExpect(expect);
		lottery.setExpectNum(expectNum);
		lottery.setOpencode(opencode);
		lottery.setOpentime(opentime);
		lottery.setInserttime(new Date());
		lottery.setLotteyType(lotteyType);
		logger.info("插入数据库:{}", lottery);
		try {
			lotteryDao.insertLottery(lottery);
		} catch (Exception e) {
			return false;
		}
		return true;
	}

	public void selectWinningResultsService(String expect) {
		// 根据期号查询
		List<WinningResultsDto> winningResultsList = winningResultsDao.selectWinningResultsByExpect(expect);
		for (WinningResultsDto winningResultsDto : winningResultsList) {

			// 获取中奖状态state和user_id和下注规则bettingrule
			int state = winningResultsDto.getState();
			String userId = String.valueOf(winningResultsDto.getUserId());
			String bettingrule = winningResultsDto.getBettingrule() + " " + winningResultsDto.getBettingMoney();
			double winningamount = winningResultsDto.getWinningamount();

			// 账户余额
			Account selectAccountByUserId = accountDao.selectAccountByUserId(winningResultsDto.getUserId());
			double accountFunds = selectAccountByUserId.getAccountFunds();

			// 下注人信息
			User selectId = userDao.selectId(winningResultsDto.getUserId());
			String userName = selectId.getUserName();
			String allBetNotice = "";

			String hget = jedisClient.hget(FLG, userId);
			if (hget == null) {
				List<InfoStateDto> list = new ArrayList<>();
				InfoStateDto info = new InfoStateDto();
				String msString = "";
				if (state == 0) {
					msString = "您于" + expect + "期投注的:" + bettingrule + " 未中奖.账户余额为:"
							+ String.format("%.2f", accountFunds) + "彩钻";
					info.setState(0);
					info.setMessage(msString);
				} else {
					msString = "您于" + expect + "期投注的:" + bettingrule + " 中奖啦!中奖金额为:"
							+ String.format("%.2f", winningamount) + "彩钻,账户余额为:" + String.format("%.2f", accountFunds)
							+ "彩钻";
					allBetNotice = "在" + expect + "期投注的:" + bettingrule + " 中奖啦!中奖金额为:"
							+ String.format("%.2f", winningamount) + "彩钻,账户余额为:" + String.format("%.2f", accountFunds)
							+ "彩钻";
					info.setState(1);
					info.setMessage(msString);
				}
				// if (state == 0) {
				// msString = "您于" + expect + "期投注的:" + bettingrule + "
				// 未中奖.账户余额为:"
				// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
				// info.setState(0);
				// info.setMessage(msString);
				// } else {
				// msString = "您于" + expect + "期投注的:" + bettingrule + "
				// 中奖啦!中奖金额为:"
				// + String.format("%.2f", winningamount - 0.005) + "彩钻,账户余额为:"
				// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
				// allBetNotice = "在" + expect + "期投注的:" + bettingrule + "
				// 中奖啦!中奖金额为:"
				// + String.format("%.2f", winningamount - 0.005) + "彩钻,账户余额为:"
				// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
				// info.setState(1);
				// info.setMessage(msString);
				// }
				list.add(info);
				String objectToJson = JsonUtils.objectToJson(list);
				jedisClient.hset(FLG, userId, objectToJson);
				logger.debug("set2 redis {} -- {}--{}", FLG, userId, objectToJson);
			} else {
				List<InfoStateDto> jsonToList = JsonUtils.jsonToList(hget, InfoStateDto.class);
				InfoStateDto info = new InfoStateDto();
				String msString = "";
				if (state == 0) {
					msString = "您于" + expect + "期投注的:" + bettingrule + " 未中奖.账户余额为:"
							+ String.format("%.2f", accountFunds) + "彩钻";
					info.setState(0);
					info.setMessage(msString);
				} else {
					msString = "您于" + expect + "期投注的:" + bettingrule + " 中奖啦!中奖金额为:"
							+ String.format("%.2f", winningamount) + "彩钻,账户余额为:" + String.format("%.2f", accountFunds)
							+ "彩钻";
					allBetNotice = "在" + expect + "期投注的:" + bettingrule + " 中奖啦!中奖金额为:"
							+ String.format("%.2f", winningamount) + "彩钻,账户余额为:" + String.format("%.2f", accountFunds)
							+ "彩钻";
					info.setState(1);
					info.setMessage(msString);
				}
				// if (state == 0) {
				// msString = "您于" + expect + "期投注的:" + bettingrule + "
				// 未中奖.账户余额为:"
				// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
				// info.setState(0);
				// info.setMessage(msString);
				// } else {
				// msString = "您于" + expect + "期投注的:" + bettingrule + "
				// 中奖啦!中奖金额为:"
				// + String.format("%.2f", winningamount - 0.005) + "彩钻,账户余额为:"
				// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
				// allBetNotice = "在" + expect + "期投注的:" + bettingrule + "
				// 中奖啦!中奖金额为:"
				// + String.format("%.2f", winningamount - 0.005) + "彩钻,账户余额为:"
				// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
				// info.setState(1);
				// info.setMessage(msString);
				// }
				jsonToList.add(info);
				String objectToJson = JsonUtils.objectToJson(jsonToList);
				jedisClient.hset(FLG, userId, objectToJson);
				logger.debug("set3 redis {} -- {}--{}", FLG, userId, objectToJson);
			}
			if (!allBetNotice.equals("")) {
				msgNoticeService.insertBetNotice(winningResultsDto.getUserId(), allBetNotice, lotteyType, agencyMark, result);
			}
		}

		// 游客开奖信息
		MessageTube messageTube = messageTubes.getSscBetMessageTube();
		for (Entry<Integer, ArrayList<LotteryExchange>> entity : TouristData.touristWin.entrySet()) {
			// MessageTube messageTube = MessageTube.getInstance();
			String userId = entity.getKey() + "";
			for (LotteryExchange one : entity.getValue()) {
				String allBetNotice = "";
				String hget = jedisClient.hget(FLG, entity.getKey() + "");
				double accountFunds = Double.parseDouble(jedisClient.hget(userId, "amount"));
				String userName = TouristData.touristInfo.get(entity.getKey()).getTouristName();
				if (hget == null) {
					List<InfoStateDto> list = new ArrayList<>();
					InfoStateDto info = new InfoStateDto();
					String msString = "";
					String betRule = one.getBettingrule() + " " + one.getBettinginfoId() + ".0";
					if (one.getWinningamount() == 0) {
						msString = "您于" + expect + "期投注的:" + betRule + " 未中奖.账户余额为:"
								+ String.format("%.2f", accountFunds) + "彩钻";
						info.setState(0);
						info.setMessage(msString);
					} else {
						msString = "您于" + expect + "期投注的:" + betRule + " 中奖啦!中奖金额为:"
								+ String.format("%.2f", one.getWinningamount()) + "彩钻,账户余额为:"
								+ String.format("%.2f", accountFunds) + "彩钻";
						allBetNotice = "在" + expect + "期投注的:" + betRule + " 中奖啦!中奖金额为:"
								+ String.format("%.2f", one.getWinningamount()) + "彩钻,账户余额为:"
								+ String.format("%.2f", accountFunds) + "彩钻";
						info.setState(1);
						info.setMessage(msString);
					}
					// if (one.getWinningamount() == 0) {
					// msString = "您于" + expect + "期投注的:" + betRule + "
					// 未中奖.账户余额为:"
					// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
					// info.setState(0);
					// info.setMessage(msString);
					// } else {
					// msString = "您于" + expect + "期投注的:" + betRule + "
					// 中奖啦!中奖金额为:"
					// + String.format("%.2f", one.getWinningamount() - 0.005) +
					// "彩钻,账户余额为:"
					// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
					// allBetNotice = "在" + expect + "期投注的:" + betRule + "
					// 中奖啦!中奖金额为:"
					// + String.format("%.2f", one.getWinningamount() - 0.005) +
					// "彩钻,账户余额为:"
					// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
					// info.setState(1);
					// info.setMessage(msString);
					// }
					list.add(info);
					String objectToJson = JsonUtils.objectToJson(list);
					jedisClient.hset(FLG, userId, objectToJson);
					logger.debug("set2 redis {} -- {}--{}", FLG, userId, objectToJson);
				} else {
					List<InfoStateDto> jsonToList = JsonUtils.jsonToList(hget, InfoStateDto.class);
					InfoStateDto info = new InfoStateDto();
					String msString = "";
					String betRule = one.getBettingrule() + " " + one.getBettinginfoId();
					if (one.getWinningamount() == 0) {
						msString = "您于" + expect + "期投注的:" + betRule + " 未中奖.账户余额为:"
								+ String.format("%.2f", accountFunds) + "彩钻";
						info.setState(0);
						info.setMessage(msString);
					} else {
						msString = "您于" + expect + "期投注的:" + betRule + " 中奖啦!中奖金额为:"
								+ String.format("%.2f", one.getWinningamount()) + "彩钻,账户余额为:"
								+ String.format("%.2f", accountFunds) + "彩钻";
						allBetNotice = "在" + expect + "期投注的:" + betRule + " 中奖啦!中奖金额为:"
								+ String.format("%.2f", one.getWinningamount()) + "彩钻,账户余额为:"
								+ String.format("%.2f", accountFunds) + "彩钻";
						info.setState(1);
						info.setMessage(msString);
					}
					// if (one.getWinningamount() == 0) {
					// msString = "您于" + expect + "期投注的:" + betRule + "
					// 未中奖.账户余额为:"
					// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
					// info.setState(0);
					// info.setMessage(msString);
					// } else {
					// msString = "您于" + expect + "期投注的:" + betRule + "
					// 中奖啦!中奖金额为:"
					// + String.format("%.2f", one.getWinningamount() - 0.005) +
					// "彩钻,账户余额为:"
					// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
					// allBetNotice = "在" + expect + "期投注的:" + betRule + "
					// 中奖啦!中奖金额为:"
					// + String.format("%.2f", one.getWinningamount() - 0.005) +
					// "彩钻,账户余额为:"
					// + String.format("%.2f", accountFunds - 0.005) + "彩钻";
					// info.setState(1);
					// info.setMessage(msString);
					// }
					jsonToList.add(info);
					String objectToJson = JsonUtils.objectToJson(jsonToList);
					jedisClient.hset(FLG, userId, objectToJson);
					logger.debug("set3 redis {} -- {}--{}", FLG, userId, objectToJson);
				}
				if (!allBetNotice.equals("")) {
					String body = userId + "::" + userName + "::" + 0 + "::" + allBetNotice;
					Message message = new Message();
					message.setMessageBody(body);
					message.setType("0");
					message.setTimestamp(new Date().getTime());
					int push = messageTube.push(message);
					logger.debug("return index={}, {},{},{}", messageTube.getHashCode(), push, message.getType(), body);
				}
			}
		}

		logger.debug("****robot :: show win infomation start***************");

		// 显示内存中的中奖信息
		// 机器人
		for (Entry<Integer, ArrayList<LotteryExchange>> entity : RobotParams.robotSscWin.entrySet()) {
			String userId = entity.getKey() + "";
			for (LotteryExchange one : entity.getValue()) {
				if (one.getWinningamount() == 0) {
					continue;
				}
				String allBetNotice = "";

				if (!RobotParams.robotinfoMap.containsKey(entity.getKey())) {
					continue;
				}
				String userName = RobotParams.robotinfoMap.get(entity.getKey()).getRobotName();

				int times = RandCodeUtil.getRandNum(3, 9);
				String robotBetInfo = AchieveDataUtil.robotDivision(one.getBettingrule()) + ".0";
				allBetNotice = "在" + expect + "期投注的:" + robotBetInfo + " 中奖啦!中奖金额为:"
						+ String.format("%.2f", one.getWinningamount()) + "彩钻,账户余额为:"
						+ String.format("%.2f", one.getWinningamount() * times) + "彩钻";
				// allBetNotice = "在" + expect + "期投注的:" + robotBetInfo + "
				// 中奖啦!中奖金额为:"
				// + String.format("%.2f", one.getWinningamount() - 0.005) +
				// "彩钻,账户余额为:"
				// + String.format("%.2f", one.getWinningamount() * times -
				// 0.005) + "彩钻";
				logger.debug("****robot sscxianshi:{}", allBetNotice);

				if (!allBetNotice.equals("")) {
					String body = userId + "::" + userName + "::" + 0 + "::" + allBetNotice;
					Message message = new Message();
					message.setMessageBody(body);
					message.setType("0");
					message.setTimestamp(new Date().getTime());
					int push = messageTube.push(message);
					logger.debug("robot return index={}, {},{},{}", messageTube.getHashCode(), push, message.getType(),
							body);
				}
			}
		}
	}

}
*/
